﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace RBAC.Web.Utilities
{
    public enum Operation { Add, Edit, Delete };
    public class MessageUtil
    {
        private static readonly string SuccessText = "success";
        private static readonly string FailText = "failure";
        private static readonly string AddText = "Add";
        private static readonly string EditText = "Edit";
        private static readonly string DeleteText = "Delete";

        public static string GetMessage(Operation op, bool? isSuccess)
        {
            string result = "";
            switch (op)
            {
                case Operation.Add:
                    result += AddText + " ";
                    break;
                case Operation.Edit:
                    result += EditText + " ";
                    break;
                case Operation.Delete:
                    result += DeleteText + " ";
                    break;
                default:
                    break;
            }
            if (isSuccess.Value)
            {
                result += SuccessText;
            }
            else
            {
                result += FailText;
            }
            return result;
        }

        public static Operation GetOperationFromString(string text)
        {
            return (Operation)System.Enum.Parse(typeof(Operation), text, true);
        }

    }
}